<?php
require_once('../practice/db.php');

pr($_POST);
pr($_FILES);

if($_FILES['i_name']['error'] == 0) {

  $file_name = date('ymdHis').'_'.rand().'_'.$_FILES['i_name']['name'];
  $source = $_FILES['i_name']['tmp_name'];
  $dest = "uploads/$file_name";

  $isUploaded = move_uploaded_file($source, $dest);
  if($isUploaded == true){
    echo "<h1>Congrats !! you have successfully uploaded one filee.</h1>";
  } else {
    echo "<h1>Your Bad !!</h1>";
  }
} else {
  echo "<h4>Something went wrong!! :( </h4>";
}
/*
 * :: Problem ::
 * a) if we upload same file again then it replace old one.
 * b) Each file must have unique name.
 * c) try to avoid copy() function for uploading of files.
 * d) use move_uploaded_file() instead.because move_uploaded_file()
 * is dedicated to upload file.
 * */
